﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <algorithm>
#include <ios>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

int dx[] = { 1,-1,0,0 };
int dy[] = { 0,0,1,-1 };

int main() {
    //个人认为广搜比较好
    int n, m;
    cin >> n >> m;
    int si, sj;//记录起始位置
    vector<vector<char>> arr(n, vector<char>(m, 0));
    vector<vector<bool>> vis(n, vector<bool>(m, false));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            char tmp;
            cin >> tmp;
            if (tmp == 'k')
            {
                si = i;
                sj = j;
            }
            arr[i][j] = tmp;
        }
    }

    int len = 0, minlen = INT_MAX, count = 0;
    queue<pair<int, int>> qu;
    qu.push({ si,sj });
    vis[si][sj] = true;
    while (qu.size())
    {
        int size = qu.size();
        len++;
        while (size--)
        {
            auto& [a, b] = qu.front();
            qu.pop();
            for (int i = 0; i < 4; i++)
            {
                int xi = a + dx[i];
                int yi = b + dy[i];
                if (xi >= 0 && xi < n && yi >= 0 && yi < m && vis[xi][yi] == false && arr[xi][yi] != '*')
                {
                    vis[xi][yi] = true;
                    if (arr[xi][yi] == 'e')
                    {
                        count++;
                        minlen = min(len, minlen);
                    }
                    else qu.push({ xi,yi });
                }
            }
        }
    }
    if (minlen == INT_MAX) cout << "-1";
    else cout << count << " " << minlen;
    return 0;
}

int main() {
    vector<vector<int>> arr{ {1,2,3},{4,5,6},{7,8,9} };
    int ret = Solution().solve(arr);
    cout << ret;
    return 0;
}
// 64 位输出请用 printf("%lld")
//1 1 1
//1 0 0
//1 0 0
//1 0 0